package com.qumitech.visualnovel.controller.rest;

import com.qumitech.visualnovel.model.common.BaseRsp;
import com.qumitech.visualnovel.model.common.ResultEnum;
import com.qumitech.visualnovel.pubdef.dto.amount.AmountQueryDTO;
import com.qumitech.visualnovel.service.social.SocialRelationService;
import com.qumitech.visualnovel.service.trend.TrendConfigService;
import com.qumitech.visualnovel.service.userStatistics.UserBehaviorStatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: ywxie
 * @Date: 2019/7/18 10:59
 * @Description:
 */
@RestController
@RequestMapping("/api/userbehaviorstatistics")
public class UserBehaviorStatisticsController {

    @Autowired
    private UserBehaviorStatisticsService userBehaviorStatisticsService;

    @GetMapping("/num")
    public BaseRsp getUserDataNum(AmountQueryDTO amountQueryDTO){
        AmountQueryDTO dto = new AmountQueryDTO(amountQueryDTO.getUid(), amountQueryDTO.getStartTime(), amountQueryDTO.getEndTime());
        Map<String, String> paramMap = new HashMap<>();
        if (dto.getUid() != null){
            paramMap.put("user_id", amountQueryDTO.getUid());
        }
        if (dto.getStartTime() != null){
            paramMap.put("start_time", amountQueryDTO.getStartTime());
        }
        if (dto.getEndTime() != null){
            paramMap.put("end_time", amountQueryDTO.getEndTime());
        }
        return new BaseRsp(ResultEnum.SUCCESS, userBehaviorStatisticsService.getUserDataNum(paramMap));
    }
}
